<template>
    <div >
    <h1>设置轮播图</h1>

    <el-form ref="form"

    :model="form" label-width="80px" @submit.native.prevent='save'>
  <el-form-item label="活动名称" style="width:50%">
    <el-input v-model="form.name" ></el-input>
  </el-form-item>
  <el-form-item label="是否授权">
    <el-switch v-model="form.delivery"></el-switch>
  </el-form-item>
    <el-form-item label="上图图片">
<el-upload
  :limit="limit"
  :action="uploadUrl"
  list-type="picture-card"
  :on-preview="handlePictureCardPreview"
  :auto-upload="true"
  :on-success="uploadSuccess"
  :on-remove="handleRemove"
  >
  <i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible">
  <img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
  </el-form-item>
    <el-row>
      <el-col :span="24">
           <vue-editor v-model="form.content"   />
      </el-col>
    </el-row>
  <el-form-item style="margin-top:30px;">
    <el-button type="primary" native-type='submin'>立即创建</el-button>
    <el-button>取消</el-button>
  </el-form-item>
</el-form>
    </div>
</template>
<script>
/**
 * 富文本插件
 *
 */
import { VueEditor } from "vue2-editor";
export default {
    data: () => ({
    content: "<h1>Some initial content</h1>"
  }),
    data(){
        return{
   dialogImageUrl: '',
        dialogVisible: false,
          limit:1,
        form: {
          name: '',//活动名字
          imgagePath:'',
          delivery: false,//是否授权
           content:'',//富文本内容
        }
        }
    },
    methods:{
 

       uploadSuccess(response, file, fileList){
          this.form.imgagePath = response.url

      },
      async save() {
      const res = await this.$http.post("/swiper",this.form)
      console.log(res)
      },

    handleRemove(file, fileList) {
      },
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = true;
      }

    },
      components: {
    VueEditor
  },


}
</script>
<style lang="scss" scoped>
.ql-snow .ql-tooltip::before {
 left:150px !important;
}
.ql-snow .ql-tooltip{
    position: absolute;

transform: translateZ(131px);
}
</style>
